#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;

int t, n;
ll ans;
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> t;
	
	for (int q = 1; q <= t; q++)
	{
		cout << "Case" <<' ' << q << ':' << '\n';
		ans = 0;
		cin >> n;
		for (int i = 1; i <= n; i++)
		{
			string s;
			cin >> s;
			if (s == "donate") {
				int tmp=0;
				cin >> tmp;
				ans += tmp;
			}
			else cout << ans << '\n';
		}
	}
	return 0;
}
